import threading
import time


class eat(threading.Thread):
    def run(self):
        for i in range(1, 5):
            print("%s 吃面条" % threading.currentThread().name)
            time.sleep(1)


class drink(threading.Thread):
    def run(self):
        for y in range(1, 5):
            print("%s 喝汤" % threading.currentThread().name)
            time.sleep(1)


# 线程1 吃面条
# 线程2 喝汤
# 线程1 吃面条
# 线程2 喝汤
# 线程2 喝汤
# 线程1 吃面条
# 线程1 吃面条
# 线程2 喝汤
if __name__ == '__main__':
    th1 = eat(name='线程1')
    th2 = drink(name='线程2')
    th1.start()
    th2.start()


# 使用类继承的话可读性更强，一看就知道多线程的，函数的话只有作为Thread的target参数传入才知道是多线程的函数
